package cn.edu.scau.cmi.guihao.pane;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.guihao.interProgramming.exmple.AnimalBehavior;
import cn.edu.scau.cmi.guihao.interProgramming.exmple.Cat;
import cn.edu.scau.cmi.guihao.interProgramming.exmple.Dog;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Pane;

public class InterfaceProgrammingPane extends Pane implements Initializable{

	@FXML
	private TextArea displayMessage;
	
	private Cat cat = new Cat();
	private Dog dog = new Dog();
	
	@Override
	public void initialize(URL location, ResourceBundle resources) {
		// TODO Auto-generated method stub
		
	}
	
	public InterfaceProgrammingPane() {
		FXMLLoader loader = new FXMLLoader(getClass().getResource("/cn/edu/scau/cmi/guihao/view/InterfaceView.fxml"));
        loader.setRoot(this);
        loader.setController(this);
        try {
            loader.load();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	public void catEating() {
		AnimalBehavior animalBehaviorOfCat = cat;
		displayMessage.appendText(cat.eating()+"\n");
	}
	
	public void dogEating() {
	    AnimalBehavior animalBehaviorOfDog = dog;
		displayMessage.appendText(dog.eating()+"\n");
	}

}
